Skip to content

Fix/430 Refactor: Remove OnceLock statics from TranslatorSv2 (#430)#431

Open
gimballock wants to merge 3 commits intostratum-mining:mainfrom
fossatmara:fix/430-issue
Open

Fix/430 Refactor: Remove OnceLock statics from TranslatorSv2 (#430)#431
gimballock wants to merge 3 commits intostratum-mining:mainfrom
fossatmara:fix/430-issue

Conversation

@gimballock
Copy link
Copy Markdown

Replace process-wide static OnceLock variables (TPROXY_MODE, VARDIFF_ENABLED)
with instance fields to fix panics during sequential integration tests.

Changes:

  • Add tproxy_mode and report_hashrate fields to ChannelManager and Sv1Server
  • Add is_aggregated() and is_non_aggregated() instance methods
  • Update all call sites to use self.is_aggregated() instead of global functions
  • Remove static OnceLocks and global helper functions from mod.rs
  • Add integration test verifying multiple TranslatorSv2 instances can run
  • Fix test naming mismatch in test_handle_set_target_without_vardiff_non_aggregated

This enables multiple TranslatorSv2 instances to be created sequentially
without panicking due to OnceLock re-initialization.

Eric Price and others added 3 commits April 13, 2026 09:38
…hotCache::refresh (stratum-mining#337)

Move all Prometheus gauge updates (set + stale-label removal) out of the
/metrics HTTP handler and into SnapshotCache::refresh(), which runs as a
periodic background task. This eliminates the GaugeVec reset gap where
label series momentarily disappeared on every scrape.

Changes:
- SnapshotCache now owns PrometheusMetrics and PreviousLabelSets
- refresh() updates snapshot data AND Prometheus gauges atomically
- /metrics handler reduced to: set uptime gauge, gather, encode
- ServerState simplified (no more PreviousLabelSets or Mutex)
- Tests updated to wire metrics through cache via with_metrics()
- Integration tests: replace fixed-sleep assertions with
  poll_until_metric_gte (100ms poll, 5s deadline) for CI resilience
- Clone impl preserves previous_labels for correct stale-label detection
- debug-level tracing on stale label removal errors
- debug_assert on with_metrics double-attachment

Closes stratum-mining#337
)

Replace process-wide static OnceLock variables (TPROXY_MODE, VARDIFF_ENABLED)
with instance fields to fix panics during sequential integration tests.

Changes:
- Add tproxy_mode and report_hashrate fields to ChannelManager and Sv1Server
- Add is_aggregated() and is_non_aggregated() instance methods
- Update all call sites to use self.is_aggregated() instead of global functions
- Remove static OnceLocks and global helper functions from mod.rs
- Add integration test verifying multiple TranslatorSv2 instances can run
- Fix test naming mismatch in test_handle_set_target_without_vardiff_non_aggregated

This enables multiple TranslatorSv2 instances to be created sequentially
without panicking due to OnceLock re-initialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants